
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
dns-over-http-resolver
Advanced tools
DNS over HTTP resolver
$ npm i dns-over-http-resolver
<script>
tagLoading this module through a script tag will make it's exports available as DnsOverHttpResolver
in the global namespace.
<script src="https://unpkg.com/dns-over-http-resolver/dist/index.min.js"></script>
Isomorphic DNS over HTTP resolver using fetch.
API based on Node.js' dns promises API, allowing the native dns
module to be used if available when relying on this API.
const DnsOverHttpResolver = require('dns-over-http-resolver')
const dohResolver = new DnsOverHttpResolver(options)
Cloudflare and Google DNS servers are used by default. They can be replaced via the API.
You can also use require('dns').promises
in Node.js in lieu of this module.
You can provide the following options for the DnsOverHttpResolver:
Name | Type | Description | Default |
---|---|---|---|
maxCache | number | maximum number of cached dns records | 100 |
Uses the DNS protocol to resolve the given host name into a DNS record.
Name | Type | Description |
---|---|---|
hostname | string | host name to resolve |
[rrType] | string | resource record type (default: 'A') |
Type | Description |
---|---|
Promise<Array<string>> | returns a Promise resolving a DNS record according to its type |
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()
const hostname = 'google.com'
const recordType = 'TXT'
const dnsRecord = await resolver.resolve(hostname, recordType)
Uses the DNS protocol to resolve the given host name into IPv4 addresses.
Name | Type | Description |
---|---|---|
hostname | string | host name to resolve |
Type | Description |
---|---|
Promise<Array<string>> | returns a Promise resolving IPv4 addresses |
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()
const hostname = 'google.com'
const address = await resolver.resolve4(hostname) // ['216.58.212.142']
Uses the DNS protocol to resolve the given host name into IPv6 addresses.
Name | Type | Description |
---|---|---|
hostname | string | host name to resolve |
Type | Description |
---|---|
Promise<Array<string>> | returns a Promise resolving IPv6 addresses |
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()
const hostname = 'google.com'
const address = await resolver.resolve6(hostname) // ['2a00:1450:4001:801::200e']
Uses the DNS protocol to resolve the given host name into a Text Record.
Name | Type | Description |
---|---|---|
hostname | string | host name to resolve |
Type | Description |
---|---|
Promise<Array<Array<string>>> | returns a Promise resolving a Text Record |
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()
const hostname = 'google.com'
const address = await resolver.resolveTxt(hostname) // [['v=spf1 -all']]
Get an array of the IP addresses currently configured for DNS resolution. These addresses are formatted according to RFC 5952. It can include a custom port.
Type | Description |
---|---|
Array<string> | returns array of DNS servers used |
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()
const servers = resolver.getServers()
Sets the IP address and port of servers to be used when performing DNS resolution. Note that the servers order will be randomized on each request for load distribution.
Name | Type | Description |
---|---|---|
servers | Array<string> | Array of RFC 5952 formatted addresses. |
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()
resolver.setServers(['https://cloudflare-dns.com/dns-query'])
Feel free to dive in! Open an issue or submit PRs.
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
DNS over HTTP resolver
The npm package dns-over-http-resolver receives a total of 51,763 weekly downloads. As such, dns-over-http-resolver popularity was classified as popular.
We found that dns-over-http-resolver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.